/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.sql.*;

/**
 *
 * @author rj
 */
public class CreateProductType {
    public static boolean createProductType(String productType){
        
        boolean done = true;
        try {
            DBConnection db = new DBConnection();
            Connection conn = db.getConnection();

            String que = "INSERT into producttype(ProductType) VALUES(?)";
            PreparedStatement pstmt =
                    conn.prepareStatement(que);


            pstmt.setString(1, productType);
            System.out.println(productType);
            pstmt.executeUpdate();
            //close DB connection
           // conn.close();

            String accType = productType + " Manager";
            DBConnection db2 = new DBConnection();
            Connection conn2 = db.getConnection();

            String que2 = "INSERT into usertype(AccountType) VALUES(?)";
            PreparedStatement pstmt2 =
                    conn.prepareStatement(que2);

            pstmt2.setString(1, accType);
            System.out.println(accType);
            pstmt2.executeUpdate();
            //close DB connection
            conn2.close();
            
            done = true;
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        return done;
    }
}
